#ifndef __TYPES_H__
#define __TYPES_H__

typedef unsigned char  uint8_kt;
typedef unsigned char  uint8_t;
typedef   signed char  sint8_kt;
typedef unsigned short uint16_kt;
typedef	unsigned short uint16_t;
typedef   signed short sint16_kt;
typedef unsigned long  uint32_kt;
typedef   signed long  sint32_kt;


typedef uint32_kt       word_kt;
typedef unsigned int    bool_kt;


typedef unsigned long uint32_t;
typedef uint32_t	word_t;

typedef void* (*pv_w_kf)(word_kt size); 
typedef bool_kt (*b_pv_kf)(void* addr);

#ifndef FALSE
#define FALSE   (0)
#endif
#ifndef TRUE
#define TRUE    (1)
#endif
#ifndef NULL
#define NULL 	(0)
#endif


typedef struct list_ks
{
    struct list_ks* prev;
    struct list_ks* next;

}   list_kt, *list_kp;

typedef struct object_ks
{
    list_kt list;
    char name[16];

} object_kt;


typedef struct list_s
{
	struct list_s	*next;
	struct list_s	*prev;

}	list_t;


typedef struct cntx_s
{
	word_t	r0;
	word_t	r1;
	word_t	r2;
	word_t	r3;
	word_t	r4;
	word_t	r5;
	word_t	r6;
	word_t	r7;
	word_t	r8;
	word_t	r9;
	word_t	r10;
	word_t	r11;
	word_t	r12;

	word_t	sp;
	word_t	lr;
	word_t	pc;
	word_t	cpsr;
	word_t  spsr;
}	cntx_t;


typedef struct timer_s
{
	list_t list;		// link on timer list
	list_t* thread;		// point to thread that need timeout service;

}   timer_t;



typedef struct tcb_s
{
	list_t	tlist;
	cntx_t* contex;
	word_t* contex_bottom;
	struct tcb_s * target;	// next thread to trans
	word_t	flag;
	word_t*	entry;
	word_t*	stack_base;
	word_t	stack_size;
	timer_t to;
	word_t cpsr;

	word_t	uid;

}	tcb_t;


#endif
